<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 适配手机端 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件实例三大属性 props</title>
</head>


<!-- react核心库 -->
<script src="../React-js/react.development.js"></script>
<!-- 操作DOM支持库 -->
<script src="../React-js/react-dom.development.js"></script>
<!-- babel转换库  jsx-js -->
<script src="../React-js/babel.min.js"></script>


<body>
    <!-- 准备好一个“容器” -->
    <div id="main"></div>
    <script type="text/babel">
        //  类组件   验证生命周期钩子函数执行顺序
        class CheckLifeSetp extends React.Component {

            constructor() {
                super()
                console.log("当前为====>constructor",);
            }

            // 将挂载  类似vue中的 created  用来做数据请求？
            componentWillMount() {
                console.log("当前为====>ComponentWillMount",);
            }
            // 挂载
            componentDidMount() {
                console.log("当前为====>componentDidMount",);
            }
            
            // 组件销毁
            componentWillUnmount() {
                console.log("当前为====>componentWillUnmount");
            }
            
            componenDeath = () => {
                ReactDOM.unmountComponentAtNode(document.getElementById('main'))
            }
            render() {
                console.log("当前为====>render");
                return (
                    <div> 验证生命周期钩子函数执行顺序
                        <button onClick={this.componenDeath}> 销毁</button>
                    </div>

                )
            }

        }

        //渲染组件
        ReactDOM.render(<CheckLifeSetp />, document.getElementById('main'))
    </script>
    </script>
</body>

</html>